<?php
#### DATETIME #################################################################
function datetime($format = false, $datetime = false) {
	if (!$format && !$datetime) return date('Y-m-d H:i:s', time());
	if (!$datetime) return false;

	if (strstr(' ', $datetime)) {
		list($date, $time) = explode(' ', $datetime);
		list($year, $month, $day) = explode('-', $date);
		list($hour, $minute, $second) = explode(':', $time);
	} else {
		list($year, $month, $day) = explode('-', $datetime);
		$hour = $minute = $second = 0;
	}
	$timestamp = mktime((int)$hour, (int)$minute, (int)$second, (int)$month, (int)$day, (int)$year);
	return date($format, $timestamp);
}
?>